package br.com.javamagazine.jdo;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class UserFoto implements Serializable {

  //O Memcache exige que a classe seja serializavel e o GAE exige em o UID seja definido
  private static final long serialVersionUID = 54321L;

  public UserFoto(String userId, Blob imageData) {
    this.userId = userId;
    this.imageData = imageData;
    this.updateTime = new Date();
  }

  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Long id;

  @Persistent
  private String userId;

  @Persistent
  private Blob imageData;

  @Persistent
  private Date updateTime;

  public void setUpdateTime(Date updateTime) {
    this.updateTime = updateTime;
  }

  public Date getUpdateTime() {
    return updateTime;
  }

  public void setImageData(Blob imageData) {
    this.imageData = imageData;
  }

  public Blob getImageData() {
    return imageData;
  }

  public void setUserId(String userId) {
    this.userId = userId;
  }

  public String getUserId() {
    return userId;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public Long getId() {
    return id;
  }

}
